/*
 * AddressManagerListItem.java
 * business
 *
 * Created by SunDing on 2016/9/9.
 *
 * Copyright (c) 2016年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.ui.widget.listview.displaylistitem;

import android.content.Context;
import android.view.View;
import android.widget.CheckBox;

import com.yidiandao.business.manager.ImageManager;
import com.yidiandao.business.ui.widget.listview.DisplayListItem;
import com.yidiandao.business.ui.widget.listview.viewholder.ChooseLocalPictureGridHolder;
import com.yidiandao.business.utils.ImageLoader;

/** 选择本地图片 */
public class ChooseLocalPictureGridItem
        extends DisplayListItem<ChooseLocalPictureGridHolder, String> {

    private OnItemClickClass mOnItemClickClass;

    public ChooseLocalPictureGridItem(String s) {
        super(s);
        mOnItemClickClass = ImageManager.getInstance().getClickListener();
    }

    @Override
    public void onShow(final Context context, final ChooseLocalPictureGridHolder holder) {
        ImageLoader.loadImage(context, holder.mImageView1, data);

        holder.mRlInfo.setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if (mOnItemClickClass != null) {
                            mOnItemClickClass.OnItemClick(data, holder.mCheckBox1);
                        }
                    }
                });

        holder.mCheckBox1.setChecked(
                ImageManager.getInstance().getCurrentImageList().contains(data));
    }

    @Override
    public String getDisplayItemTag() {
        return ChooseLocalPictureGridItem.class.getSimpleName();
    }

    @Override
    public Class<ChooseLocalPictureGridHolder> getViewHolderClazz() {
        return ChooseLocalPictureGridHolder.class;
    }

    public interface OnItemClickClass {
        void OnItemClick(String path, CheckBox checkBox);
    }
}
